cmake_minimum_required(VERSION 3.0)
project(miniSafeTrans)

set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_BUILD_TYPE Debug)
#先不加优化选项，将cmake配置为debug模式
set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -rdynamic -fPIC -ggdb -std=c++11 -Wall -Wno-deprecated -Werror -Wno-unused-function -Wno-builtin-macro-redefined -Wno-deprecated-declarations")
# set(CMAKE_C_FLAGS "$ENV{CXXFLAGS} -rdynamic -O3 -fPIC -ggdb -std=c11 -Wall -Wno-deprecated -Werror -Wno-unused-function -Wno-builtin-macro-redefined -Wno-deprecated-declarations")
# 重定义__FILE__的宏
include(cmake/utils.cmake)
#添加头文件
include_directories(./src)
#添加库文件
link_directories(/usr/local/lib)
link_directories(/usr/local/lib64)
IF(UNIX)
    #包含在linux下安装软件的库
    include_directories(/usr/local/include)
ENDIF()
#find_package(Boost REQUIRED)
#if(Boost_FOUND)
#    include_directories(${Boost_INCLUDE_DIRS})
#endif()

set(LIB_SRC
    #编解码以及编解码的工厂
    src/codec.cc
    src/codecFactory.cc
    #通信socket和TCP服务器
    src/tcpSocket.cc
    src/tcpServer.cc
    #protobuf生成文件
    src/requestMsg.pb.cc
    src/respondMsg.pb.cc
    #线程池
    src/threadpool.cc
    #常用的单个函数，如单例包装类
    src/util.cc
    #断言、打印堆栈
    src/macro.cc
    src/log.cc
    src/config.cc
    #共享内存API的封装
    src/baseShm.cc
    #openssl相关函数封装
    src/myhash.cc
    src/myrsa.cc
    src/myAes.cc
    src/mysqldb.cc
    src/mysqldb.cc
    src/server/serverOp.cc
    src/server/mysqlop.cc
    src/client/ClientOption.cc
    )
add_library(daniel SHARED ${LIB_SRC})

# set(
#     LIB_CLIENT
#     src/client/ClientOption.cc
# )   
# add_library(client SHARED ${LIB_CLIENT})
# set(
#     LIB_SERVER
#     src/server/serverOp.cc
# )
# add_library(server SHARED ${LIB_SERVER})
# force_redefine_file_macro_for_sources(daniel)
#protobufmaker(sylar/ns/ns_protobuf.proto LIB_SRC ${CMAKE_CURRENT_SOURCE_DIR})

#add_library(sylar SHARED ${LIB_SRC})
#add_library(sylar_static STATIC ${LIB_SRC})
#SET_TARGET_PROPERTIES (sylar_static PROPERTIES OUTPUT_NAME "sylar")

#find_library(YAMLCPP yaml-cpp)
find_library(PTHREAD pthread)
find_library(PROTOBUF protobuf)

set(LIBS
        daniel
        # client
        # server
        protobuf
        pthread
        jsoncpp
        yaml-cpp
        crypto
        mysqlclient
    )
# add_executable(test_proto "tests/test_proto.cc")   接口修改，导致测试文件有些问题
# target_link_libraries(test_proto ${LIBS})

add_executable(test_threadpool.out "tests/test_threadpool.cc")
target_link_libraries(test_threadpool.out ${LIBS})

add_executable(test_singleton.out "tests/test_singleton.cc")
target_link_libraries(test_singleton.out ${LIBS})

add_executable(test_macro.out "tests/test_macro.cc")
target_link_libraries(test_macro.out ${LIBS})

add_executable(test_tcp.out "tests/test_tcp.cc")
target_link_libraries(test_tcp.out ${LIBS})

add_executable(test_log.out "tests/test_log.cc")
target_link_libraries(test_log.out ${LIBS})
force_redefine_file_macro_for_sources(test_log.out)
# set_target_properties(bin_sylar PROPERTIES OUTPUT_NAME "sylar")
add_executable(test_tcpclient.out "tests/test_tcpclient.cc")
target_link_libraries(test_tcpclient.out ${LIBS})

add_executable(test_shm1.out "tests/test_shm1.cc")
target_link_libraries(test_shm1.out ${LIBS})

add_executable(test_shm2.out "tests/test_shm2.cc")
target_link_libraries(test_shm2.out ${LIBS})

add_executable(test_config.out "tests/test_config.cc")
target_link_libraries(test_config.out ${LIBS})

add_executable(test_rsa.out "tests/test_rsa.cc")
target_link_libraries(test_rsa.out ${LIBS})

add_executable(main_client.out "src/client/main_client.cc")
target_link_libraries(main_client.out ${LIBS})

add_executable(main_server.out "src/server/main_server.cc")
target_link_libraries(main_server.out ${LIBS})

add_executable(test_mysql.out "tests/test_mysql.cc")
target_link_libraries(test_mysql.out ${LIBS})


SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)